﻿package com.jfdesgagne.jfdesgagne09.section.showcase.model {
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import com.jfdesgagne.jfdesgagne09.core.service.RemotingGateway;
	import com.jfdesgagne.jfdesgagne09.section.showcase.event.ProjectsLoadedEvent;
	import com.jfdesgagne.jfdesgagne09.section.showcase.service.ProjectsService;
	
	public dynamic class ShowcaseModel extends EventDispatcher {
		public var projects:Object;
		
		public function ShowcaseModel($gateway:RemotingGateway) {
			this.productsService = new ProjectsService($gateway);
		}
		
		public function loadProjects():void {
			this.productsService.addEventListener(ProjectsLoadedEvent.COMPLETE, this._projectsLoadedHandler);
			this.productsService.loadProjects();
		}
		
		private function _projectsLoadedHandler($event:ProjectsLoadedEvent):void {
			this.projects = $event.data;
			this.dispatchEvent($event); 
		}
		
	}
}
		
		